package com.example.aop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class MyAspectDemo {
    @Around("@annotation(com.example.aop.config.MyAspect)")
    public Object doArount(ProceedingJoinPoint joinPoint) {
        log.info("my aspect do around before...");
        Object o = null;
        try {
             o = joinPoint.proceed();
        } catch (Throwable e) {
            log.error("发生异常, e:", e);
            throw new RuntimeException(e);
        }
        log.info("my aspect do around after");
        return o;
    }
}
